from django.db import models

class Product(models.Model):
    name = models.CharField(max_length=100)
    slug = models.SlugField(blank=True)
    description = models.TextField(blank=True)
    main_content = models.TextField(blank=True)
    additional_info = models.TextField(blank=True)
    specification = models.TextField(blank=True)
    image = models.ImageField(blank=True, null=True, upload_to="media")
    product_accessories = models.ManyToManyField("ProductAccessories", blank=True, null=True)
    active = models.BooleanField(help_text="The post will only show on the frontend if the 'live' box is checked")
    
   
    def __unicode__(self):
        return self.name
    
    @models.permalink
    def get_absolute_url(self):
        return ('products', (), {
                'slug': self.slug,     
             })
        
class ProductAccessories(models.Model):
    name = models.CharField(max_length=100)
    slug = models.SlugField(blank=True)
    description = models.TextField(blank=True)
    active = models.BooleanField(help_text="The post will only show on the frontend if the 'live' box is checked")
    
    def __unicode__(self):
        return self.name